const {
	defineConfig
} = require('@vue/cli-service')
const path = require('path')

module.exports = defineConfig({
	transpileDependencies: true,
})
const webpack = require('webpack')

function resolve(dir) {
	return path.join(__dirname, dir)
}
module.exports = {
	publicPath: "./",
	assetsDir: "static", //静态资源目录（js, css, img）
	outputDir: 'dist',
	lintOnSave: false,
	devServer: {
		open: true, //是否自动弹出浏览器页面
		// host: "192.168.3.19",
		host: "127.0.0.1",
		port: '8083',
		// public: '0.0.0.0:9528',
		https: false, //是否使用https协议
		// hotOnly: true, //是否开启热更新
		hot: true, //是否开启热更新
		proxy: {
			'/api': {
				// target: 'https://manage.bhnewechat.com', //目标服务器的地址
				// target: 'https://ceshi.bhnewechat.com', //目标服务器的地址
				// target: 'http://120.48.151.239:9080', //高佳培
				target: 'http://127.0.0.1:9080', //高佳培
				// target: 'https://mzj.bhnewechat.com', //目标服务器的地址  //admin/derd12345!
				// target: 'http://117.15.170.46:33080', //目标服务器的地址
				ws: true, //代理websockets
				changeOrigin: true, // 虚拟的站点需要更管origin
				pathRewrite: { //重写路径 比如'/api/aaa/ccc'重写为'/aaa/ccc'
					'^/api': ''
				},
				onProxyRes(proxyRes, req, res) {
					var cookies = proxyRes.headers['set-cookie']
					if (cookies == null || cookies.length == 0) {
						delete proxyRes.headers['set-cookie']
						return
					}
					for (var i = 0, n = cookies.length; i < n; i++) {
						if (cookies[i].match(/^JSESSIONID=[^;]+;[\s\S]*Path=\/[^;]+/)) {
							cookies[i] = cookies[i].replace(/Path=\/[^;]+/, 'Path=/');
						}
					}
					proxyRes.headers['set-cookie'] = cookies;
				}
			}
		}
	}
}